// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_REP_CHECK_INFO_ITEM
// * CreateDate    : 2011-12-26 11:08:53
// * Creater       : CodeSmith
// * LastChangeDate: 2011-12-26 11:08:53
// * LastChanger   : 2011-12-26 11:08:53
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESOL.Common.Entity;
using Suzsoft.Smart.Data;
using System.Data;
using ESOL.Common;

namespace ESOL.Business.Rep
{
/// <summary>
    /// RepCheckInfoItem
    /// </summary>
    public partial class RepCheckInfoItemBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objRepCheckInfoItemEntity">Entity</param>
        /// <returns>Entity</returns>
        public static RepCheckInfoItemEntity GetRepCheckInfoItem(RepCheckInfoItemEntity objRepCheckInfoItemEntity)
        {
            return DataAccess.SelectSingle<RepCheckInfoItemEntity>(objRepCheckInfoItemEntity);
        }
        #endregion


        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objRepCheckInfoItemEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertRepCheckInfoItem(RepCheckInfoItemEntity objRepCheckInfoItemEntity)
        {
            return DataAccess.Insert(objRepCheckInfoItemEntity);
        }

        public static bool InsertRepCheckInfoItem(List<RepCheckInfoItemEntity> objRepCheckInfoItemEntityList)
        {
            return DataAccess.Insert(objRepCheckInfoItemEntityList);
        }
        #endregion


        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objRepCheckInfoItemEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateRepCheckInfoItem(RepCheckInfoItemEntity objRepCheckInfoItemEntity)
        {
            return DataAccess.Update(objRepCheckInfoItemEntity);
        }

        public static bool UpdateRepCheckInfoItem(List<RepCheckInfoItemEntity> objRepCheckInfoItemEntityList)
        {
            return DataAccess.Update<RepCheckInfoItemEntity>(objRepCheckInfoItemEntityList);
        }
        #endregion


        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objRepCheckInfoItemEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteRepCheckInfoItem(RepCheckInfoItemEntity objRepCheckInfoItemEntity)
        {
            return DataAccess.Delete(objRepCheckInfoItemEntity);
        }

        public static bool DeleteRepCheckInfoItem(List<RepCheckInfoItemEntity> objRepCheckInfoItemEntityList)
        {
            return DataAccess.Delete<RepCheckInfoItemEntity>(objRepCheckInfoItemEntityList);
        }
        #endregion


        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetRepCheckInfoItemAll()
        {
            return DataAccess.SelectAllDataSet<RepCheckInfoItemEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<RepCheckInfoItemEntity> GetRepCheckInfoItemAllList()
        {
            return DataAccess.SelectAll<RepCheckInfoItemEntity>();
        }
        #endregion

        #region Functions
        public static DataTable GetDtRepCheckInfoItemByCheckInfoID(string CheckInfoID)
        {
            if (string.IsNullOrEmpty(CheckInfoID))
                return null;
            string Sql = @"SELECT RCII.*,MP.PRODUCT_CODE,MP.PRODUCT_NAME,RRI.QTY AS PLAN_QTY,
                RRI.UNIT,RRI.PRODUCT_SPEC_IN,RRI.PRODUCT_SPEC_OUT,RRI.MATERIAL 
                FROM REP_CHECK_INFO_ITEM RCII
                LEFT JOIN MST_PRODUCT MP ON RCII.PRODUCT_ID=MP.PRODUCT_ID
                INNER JOIN REP_REGISTER_ITEM RRI ON RCII.REGISTER_ITEM_ID=RRI.REGISTER_ITEM_ID
                WHERE RCII.CHECK_INFO_ID='" + CheckInfoID + "'";
            DataSet ds = DataAccess.SelectDataSet(Sql);
            if (ds != null && ds.Tables[0] != null)
            {
                return ds.Tables[0];
            }
            return null;
        }

        public static DataTable GetDtRepCheckInfoItemByRegisterID(string RegisterID)
        {
            if (string.IsNullOrEmpty(RegisterID))
                return null;
            string Sql = @"SELECT RCII.*,RRI.*,MP.PRODUCT_CODE,MP.PRODUCT_NAME FROM 
                REP_REGISTER_ITEM RRI 
                LEFT JOIN REP_CHECK_INFO_ITEM RCII ON RRI.REGISTER_ITEM_ID=RCII.REGISTER_ITEM_ID
                INNER JOIN MST_PRODUCT MP ON RCII.PRODUCT_ID=MP.PRODUCT_ID WHERE RRI.REGISTER_ID='" + RegisterID + "'";
            DataSet ds = DataAccess.SelectDataSet(Sql);
            if (ds != null && ds.Tables[0] != null)
            {
                return ds.Tables[0];
            }
            return null;
        }

        public static DataTable GetDtRepCheckInfoItemByRegisterItemID(string RegisrerItemID)
        {
            if (string.IsNullOrEmpty(RegisrerItemID))
                return null;
            string Sql = @"SELECT * FROM REP_CHECK_INFO_ITEM RCII
                WHERE RCII.REGISTER_ITEM_ID='" + RegisrerItemID + "'";
            DataSet ds = DataAccess.SelectDataSet(Sql);
            if (ds != null && ds.Tables[0] != null)
            {
                return ds.Tables[0];
            }
            return null;
        }

        public static RepCheckInfoItemEntity GetCheckInfoItemByID(string ID)
        {
            if (string.IsNullOrEmpty(ID))
                return null;
            RepCheckInfoItemEntity m = new RepCheckInfoItemEntity();
            m.CheckInfoItemId = ID;
            return DataAccess.SelectSingle<RepCheckInfoItemEntity>(m);
        }
        #endregion
    }
	
	
}	

